<template>
  <div>
    <el-col style="margin-bottom: 20px" :span="24" :key="item.value" v-for="(item,index) in initSelect.content_type">
      <el-col :span="24" style="margin-bottom: 5px">
        <div style="float: left"><h2>{{item.label}}</h2></div>
        <div style='float: right;font: 16px / 26px "Microsoft YaHei";'><a @click="more(index)">更多>>></a></div>
      </el-col>
      <hr style="color: #9c3;background-color: #9c3;height: 3px"/>
      <el-col :span="12" style="padding-top: 10px;padding-bottom: 10px" :key="items.id" v-for="(items,index) in contentMap[item.value]">
        <el-col :span="2" v-if="index % 2 != 0">&emsp;</el-col>
        <el-col :span="22">
          <div style="float: left"><i class="el-icon-notebook-2"></i><a @click="toDts(items.title,items)">{{items.title.length >= 10 ? items.title.substring(0,10) + `...` : items.title}}</a></div>
          <div style="float: right;font-size: 15px;color: #999">{{items.create_date}}</div>
        </el-col>
        <el-col :span="2" v-if="index % 2 == 0">&emsp;</el-col>
      </el-col>
    </el-col>
  </div>
</template>

<script>
  export default {
    name: "userDefault",
    data() {
      return {
        activeIndex: '1',
        addParam: {
          queryName: ''
        },
        initSelect: {
          content_type: [{label: '饲养', value: 1}, {label: '医疗', value: 2}, {label: '训练', value: 3}],
        },
        contentRoute: {
          0:'/userHome/contentDts',
          1:'/article/contentDts',
          2:'/info/contentDts',
          3:'/video/contentDts',
        },
        contentMap:{}
      }
    },
    props: ['id'],
    created() {
      this.initList()
    },
    methods: {
      more(id){
        this.$router.push("/more/more/" + this.id + "/" + id)
      },
      initList(){
        this.service.get('/tbArticleInformation/defaultData?type='+this.id)
          .then(result => {
            let data = result.data.data
            this.contentMap = data
          })
      },
      handleSelect(key, keyPath) {
        this.$router.push(key)
      },
      toDts(name,item) {
        let json = JSON.stringify(item);
        sessionStorage.setItem("contentDts",json)
        this.$router.push({path: this.contentRoute[this.id] + "/" + name})
      }
    }
  }
</script>

<style scoped>

</style>
